/*
 *   Copyright (C) 2011 David Swords
 *	
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package locate;

import java.util.Vector;

public class Pose {

	private final String class_details = "Pose.";
	private Vector< Double > pose;
	
	public Pose(double x, double y, double t) {
		final String constructor_details = class_details + "Pose(double, double, double)";
		chk(!(t >= 0 && t <= 2*Math.PI), "The double t is outside of 0 to 2*PI range with " + t, constructor_details);
		pose = new Vector < Double >();
		chk(pose == null, "The Vector< Double > pose is equal to null, please initialise.", constructor_details);
		pose.add(x);
		pose.add(y);
		pose.add(t);
		chk(pose.isEmpty(), "The Vector< Double > pose is empty.", constructor_details);
	}
	
	private void chk(final boolean expression, final String message, final String location) {
		if(expression) {
			System.err.println("#############################################################");
			System.err.println(message);
			System.err.println(location);
			System.err.println("#############################################################");
			System.exit(1);
		}
	}
	
	public double x() {
		final String method_details = class_details + "x() returns double";
		chk(pose == null, "The Vector< Double > pose is equal to null, please initialise.", method_details);
		chk(pose.isEmpty(), "The Vector< Double > pose is empty.", method_details);
		return pose.get(0);
	}
	
	public double y() {
		final String method_details = class_details + "y() returns double";
		chk(pose == null, "The Vector< Double > pose is equal to null, please initialise.", method_details);
		chk(pose.isEmpty(), "The Vector< Double > pose is empty.", method_details);
		return pose.get(1);
	}
	
	public double t() {
		final String method_details = class_details + "t() returns double";
		chk(pose == null, "The Vector< Double > pose is equal to null, please initialise.", method_details);
		chk(pose.isEmpty(), "The Vector< Double > pose is empty.", method_details);
		return pose.get(2);
	}
}
